package cn.tedu.egweibo5.base.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @Author: Miyako
 * @CreateTime: 2024-08-14  20:16
 * @Description: TODO
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {

    private Integer status;
    private String message;
    private Object data;


    public JsonResult(StatusCode statusCode){
        status=statusCode.getStatus();
        message=statusCode.getMessage();
    }

    public JsonResult(StatusCode statusCode , Object data){
        this(statusCode);
        this.data=data;
    }


    public static JsonResult ok(Object data){
       return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }


    public static JsonResult filed(Object data){
        return new JsonResult(StatusCode.OPERATION_FAILED,data);
    }

}
